package net.qhzw.admin.controller;

import net.qhzw.admin.param.DictParam;
import net.qhzw.admin.query.DictQuery;
import net.qhzw.admin.service.SysDictService;
import net.qhzw.common.model.BaseQuery;
import net.qhzw.common.model.JsonResult;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RequestMapping("sys/dict")
@RestController
public class SysDictController {



    @Autowired
    private SysDictService dictService;



    /***
     * 获取当前字典
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public JsonResult getDict(@PathVariable(value = "id") String id){
        return dictService.getDict(id);
    }


    /***
     * 获取当前字典列表
     * @param query 查询条件
     * @return 字典列表
     */
    @GetMapping
    public JsonResult getDictList(DictQuery query){
        return dictService.getDictList(query);
    }


    /***
     * 添加字典
     * @param param
     * @return
     */
    @PostMapping
    public JsonResult addDictList(@RequestBody DictParam param){
        return dictService.edit(param);
    }


    /***
     * 修改字典 revise
     * @param param
     * @return
     */
    @PutMapping
    public JsonResult uploadDictList(@RequestBody DictParam param){
        return dictService.edit(param);
    }

    /***
     * 删除字典
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    public JsonResult deleteDictList(@PathVariable(value = "id") String id){
        return dictService.deleteDictList(id);
    }


    /***
     * 查询字典表下拉框
     * @param code
     * @return
     */
    @GetMapping("selectBox")
    public JsonResult selectBox(@RequestParam String code){
        return dictService.selectBox(code);
    }


}
